#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main() {
    if(freopen("in.txt", "r", stdin)==NULL) {
        cout<<"Error: input file can't be opened";
        return 1;
    }

    size_t n;
    cin>>n;
    double* input = new double[n];
    for (size_t i = 0; i < n; ++i) {
        cin>>input[i];
    }

    size_t msize = (int)log((double)n) / log(2.0)+1;

    vector<vector<int> > M(n, vector<int>(msize));
    for (size_t i=0; i < n; ++i) {
        M[i][0] = i;
    }

    for (size_t i=1; i < msize; ++i) {
        for (size_t j=0; j < n - (1<<i) + 1; ++j) {
            M[j][i]=input[ M[j][i - 1] ] < input[ M[j + (1<<(i-1))][i - 1] ]
            ? M[j][i - 1]
            : M[j + (1<<(i-1))][i-1];
        }
    }

    size_t amountOfRequests;
    cin>>amountOfRequests;

    for (size_t t = 0; t < amountOfRequests; ++t) {
        int i,j;
        cin>>i>>j;
        --j;
        if (i<0 || i>n || j<0 || j>n || i>j) {
            cout<<"Error: invalid index"<<endl;
            return 1;
        }
        int k=(int) floor(log((double)j - i + 1) / log(2.0));
        cout<<min(input[M[i][k]], input[M[j-(1<<k)+1][k]])<<endl;
    }

    delete[] input;

    return 0;
}